###基本方法
println("基本方法：")
#数据类型
println("typeof","：",typeof(1)) #> Int64
#数据类型最小值
println("typemin","：",typemin(Int8)) #> -128
#数据类型最大值
println("typemax","：",typemax(Int8)) #> 127
#二进制表示
println("bitstring","：",bitstring(1)) #> 0000000000000000000000000000000000000000000000000000000000000001
#机器精度,eps函数也可以接受一个浮点值作为参数，然后给出这个值与下一个可表示的值的绝对差
println("eps","：",eps(Float64)) #> 2.220446049250313e-16

x = 1.25f0
println("nextfloat","：",nextfloat(x)) #> 1.2500001
println("prevfloat","：",prevfloat(x)) #> 1.2499999
println("bitstring(nextfloat)","：",bitstring(nextfloat(x))) #> 00111111101000000000000000000001
println("bitstring(prevfloat)","：",bitstring(prevfloat(x))) #> 00111111100111111111111111111111

#数据类型转换
println("parse","：",(parse(BigInt, "12345678901234567890") + 1)) #> 12345678901234567891

println("--------")
function g(x,y)::Int8
   return x * y
   x + y
end
f(x,y)::Int8 = x + y
∑(x,y) = x + y
println("myfunction", "：", f(3,4), " | ", g(3,4), " | ", ∑(3,4)) #> 7

println("操作符+", "：", +(1,2,3)) #> 6

println("可变参数")
function plot(x, y; style="solid", width=1, color="black")
    println("x=",x, "|y=", y, "|style=", style, "|width=", width, "|color=", color);
end
plot(1, 2)
plot(3, 5, width=2,style="sss")

function f(;x::Int=1)
    println("f:",x)
end
f(x=2)
function f(x, y)
    println("f:",x,"|",y)
end
f(3, 5)

println("loop")
A = [1, 0, -2]
B = [4.0, 5.0, 6.0];

f.(A,B)

B1 = sin.(cos.(B)) #equal
B2 = broadcast(x -> sin(cos(x)), B) #equal
for x in B sin(cos(x)) #equal
end

B3 = similar(B);
B3 .= sin.(cos.(B))
B4 = similar(B);
@. B4 = sin(cos(B))
println("B:",B,"|",B1,"|",B2,"|",B3,"|",B4)

B = map(x->begin
           if x < 0 && iseven(x)
               return 0
           elseif x == 0
               return 1
           else
               return x
           end
       end,
    A)

C = map(A) do x
        if x < 0 && iseven(x)
            return 0
        elseif x == 0
            return 1
        else
            return x
        end
    end
println(A, B,C)
#map(func, [A, B, C])
